import business.Bank;
import business.BankFactory;
import business.BankOperation;
import business.ReplaceMoneyOperation;
import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * Created by aleks_000 on 25.12.13.
 */
public class Program {

    public static void main(String[] args) {
        Random random = new Random();

        Bank bank = BankFactory.createBank(10, 10, 100);



        BankOperation[] operations = new BankOperation[100];
        for (int i = 0; i < operations.length; ++i) {
            operations[i] = new ReplaceMoneyOperation(random.nextInt(11), random.nextInt(11), 10, bank);
        }

        final int operationPerCashier = operations.length/bank.getCashiersCount();
        for (int i = 0; i < bank.getCashiersCount(); ++i) {
            for (int j = 0; j < operationPerCashier; ++j)
                bank.getCashier(i).enqueueOperation(operations[i*operationPerCashier + j]);
        }


        try {
            TimeUnit.SECONDS.sleep(120);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        double totalMoney = 0;
        for (int i = 0; i < bank.getAccountsCount(); ++i) {
            totalMoney += bank.getAccount(i).getValue();
        }
        System.out.println(totalMoney);
    }
}
